package com.acme.bankapp.domain.bank;

import java.io.Serializable;

@SuppressWarnings("serial")
public class Client implements Serializable
{	
	private static int count;
	private int id;
	private Gender gender;	
	private Account account;
	private String name;
	private String email;

	@Override
	public int hashCode() {
		return id;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Client other = (Client) obj;
		return other.id == this.id;
	}

	public String getName() {
		return name;
	}	
	
	@Override
	public String toString() {		
		StringBuffer sbuffer = new StringBuffer();
		sbuffer.append("Client #" + id + " [name=" + gender + name + "]");
		sbuffer.append("[account=" + account + "]");
		sbuffer.append("[email="+email+"]");
		return sbuffer.toString();
	}
	
	public String getClientSalutation() {
		return gender.toString()+name;
	}
	
	public Account getAccount() {
		return account;
	}

	public Client(String name, Gender gender, Account account, String email) {
		Client.count++;
		this.id = Client.count;
		this.name = name;
		this.gender = gender;
		this.account = account;
		this.email = email;
	}	
	
	public String getEmail() {
		return this.email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
}
